import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/core/utils/user_manager.dart';
import 'package:enterprise_v6_app/app/data/entities/application/basic_information/certificate_file_entity.dart';
import 'package:enterprise_v6_app/app/modules/profile/controller.dart';

class HomeMyCertController extends GetxController {
  final profile = Get.find<HomeMyController>();

  /// 证照列表
  List<CertificateFileEntity> fileList = [];

  @override
  void onInit() {
    super.onInit();
    initData();
  }

  /// 获取数据
  /// 初始化审批流程数据
  Future<void> initData() async {
    // 获取审批流程数据
    final res = await HttpUtil().generateGetRequest<CertificateFileEntity>(
      Interface.getCertificateFileByUserId,
      queryParameters: {'userId': UserManager.getUserId()},
    ).execute();

    res.onSuccess((result) {
      // 目前暂时为显示一个,可能会改为多个
      if (result.data != null) {
        fileList.clear();
        fileList.add(result.data!);
        update();
      }
    });
  }
}
